/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelPC.java
 *
 * Created on 06/08/2011, 19:06:42
 */
package tsb.UI.Paneles.PC;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.KeyEvent;
import tsb.dominio.interfaces.*;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import tsb.UI.Paneles.PanelModem;
import tsb.UI.Paneles.PanelSerial;
import tsb.UI.Paneles.PanelWireless;
import tsb.UI.Ventanas.VentanaDeError;
import tsb.UI.Ventanas.VentanaPC;
import tsb.UI.consola.Arbol;
import tsb.UI.consola.Consola;
import tsb.dominio.dispositivos.hosfinal.PC;
import tsb.dominio.enumeraciones.AsignacionIP;
import tsb.gestores.GestorGrafo;

/**
 *
 * @author Fede
 */
public class PanelPC extends javax.swing.JPanel {
    
   // private int cantidadInterfaces=0; // para controllar la contidad de interfaces que tiene
    private boolean pestaña1=true; // para saber si la pestaña ya tiene un panel
    private boolean pestaña2=false; // para saber si la pestaña ya tiene un panel
   private VentanaPC ventanaPC;
    //private ArrayList<InterfaceDeConeccion> listaInterfaces;
    
    //para las imagenes del combobox Encendido
    ImageIcon[] images;
    String[] opciones = {"Si","No"};
    Integer[] intArray;
    

    private Consola cons;
    private Arbol arbol;

    /** Creates new form PanelPC */
    public PanelPC(VentanaPC ventanaPc) {
        this.ventanaPC=ventanaPc;
        images = new ImageIcon[opciones.length];
        intArray = new Integer[opciones.length];
        for (int i = 0; i < opciones.length; i++) {
            intArray[i] = new Integer(i);
            if(i==0)
            {images[i] = new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/PRENDIDO_16X16.png"));
            }
            else
            {images[i] = new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/APAGADO_16X16.png"));
            }
            if (images[i] != null) {
                images[i].setDescription(opciones[i]);
            }
        }
        initComponents();
        
        ComboBoxRenderer renderer= new ComboBoxRenderer();
        renderer.setPreferredSize(new Dimension(10, 20));
        this.cmbEncendido.setRenderer(renderer);
        
        
     
        this.btnQuitarInterfazPestaña2.setVisible(false);
        
       // listaInterfaces = new ArrayList<InterfaceDeConeccion>();
        
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btgrAsingacionIP = new javax.swing.ButtonGroup();
        PestañasConfiguraciones = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        txtNombreAMostrar = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        cmbEncendido = new javax.swing.JComboBox(intArray);
        jLabel1 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtGateway = new javax.swing.JTextField();
        txtServidorDNS = new javax.swing.JTextField();
        rbtDCHP = new javax.swing.JRadioButton();
        rbtStatic = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        cmbIntefaces = new javax.swing.JComboBox();
        btnAgregar = new javax.swing.JButton();
        pestañasInterfaces = new javax.swing.JTabbedPane();
        panelPestaña1 = new javax.swing.JPanel();
        panelPestaña2 = new javax.swing.JPanel();
        btnQuitarInterfazPestaña2 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        panelConsola = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtAConsola = new javax.swing.JTextArea();
        txtComando = new javax.swing.JTextField();

        setBackground(new java.awt.Color(255, 255, 255));

        PestañasConfiguraciones.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        txtNombreAMostrar.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel2.setText("Nombre a Mostrar:");

        cmbEncendido.setBackground(new java.awt.Color(240, 240, 240));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Encendido:");

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Gateway/DNS"));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel4.setText("Forma de Asignacion IP:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel3.setText("Gateway:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel5.setText("Servidor DNS:");

        txtGateway.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtGateway.setEnabled(false);

        txtServidorDNS.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtServidorDNS.setEnabled(false);

        rbtDCHP.setBackground(new java.awt.Color(255, 255, 255));
        btgrAsingacionIP.add(rbtDCHP);
        rbtDCHP.setFont(new java.awt.Font("Tahoma", 0, 14));
        rbtDCHP.setSelected(true);
        rbtDCHP.setText("DHCP");
        rbtDCHP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rbtDCHPMouseClicked(evt);
            }
        });

        rbtStatic.setBackground(new java.awt.Color(255, 255, 255));
        btgrAsingacionIP.add(rbtStatic);
        rbtStatic.setFont(new java.awt.Font("Tahoma", 0, 14));
        rbtStatic.setText("Static");
        rbtStatic.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rbtStaticMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbtStatic)
                            .addComponent(rbtDCHP)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtServidorDNS)
                            .addComponent(txtGateway, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(rbtDCHP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbtStatic)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtGateway, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtServidorDNS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtNombreAMostrar, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE))
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(100, 100, 100))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(119, 119, 119)
                                .addComponent(cmbEncendido, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(222, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtNombreAMostrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cmbEncendido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(188, Short.MAX_VALUE))
        );

        PestañasConfiguraciones.addTab("Configuraciones", new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/CONFIGURACIONES2_16X16.png")), jPanel1); // NOI18N

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        cmbIntefaces.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ethernet", "Fast Ethernet RJ45", "Fast Ethernet Fibra Optica", "Gigabit RJ45", "Gigabit Fibra Optica", "Modem", "Serial", "Wireless" }));

        btnAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/add16x16.png"))); // NOI18N
        btnAgregar.setText("Agregar");
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        panelPestaña1.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout panelPestaña1Layout = new javax.swing.GroupLayout(panelPestaña1);
        panelPestaña1.setLayout(panelPestaña1Layout);
        panelPestaña1Layout.setHorizontalGroup(
            panelPestaña1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 398, Short.MAX_VALUE)
        );
        panelPestaña1Layout.setVerticalGroup(
            panelPestaña1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 354, Short.MAX_VALUE)
        );

        pestañasInterfaces.addTab("Interfaz 1", panelPestaña1);

        panelPestaña2.setBackground(new java.awt.Color(255, 255, 255));

        btnQuitarInterfazPestaña2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/eliminar16x16.png"))); // NOI18N
        btnQuitarInterfazPestaña2.setText("Quitar Interfaz");
        btnQuitarInterfazPestaña2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarInterfazPestaña2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelPestaña2Layout = new javax.swing.GroupLayout(panelPestaña2);
        panelPestaña2.setLayout(panelPestaña2Layout);
        panelPestaña2Layout.setHorizontalGroup(
            panelPestaña2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPestaña2Layout.createSequentialGroup()
                .addContainerGap(273, Short.MAX_VALUE)
                .addComponent(btnQuitarInterfazPestaña2))
        );
        panelPestaña2Layout.setVerticalGroup(
            panelPestaña2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPestaña2Layout.createSequentialGroup()
                .addContainerGap(329, Short.MAX_VALUE)
                .addComponent(btnQuitarInterfazPestaña2))
        );

        pestañasInterfaces.addTab("Interfaz 2", panelPestaña2);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel6.setText("Interfaces de Conección");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pestañasInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmbIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAgregar))
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgregar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pestañasInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 382, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        PestañasConfiguraciones.addTab("Interfaces", new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/CONEXIONES_16X16.png")), jPanel2); // NOI18N

        panelConsola.setBackground(new java.awt.Color(255, 255, 255));

        txtAConsola.setBackground(new java.awt.Color(0, 0, 0));
        txtAConsola.setColumns(20);
        txtAConsola.setFont(new java.awt.Font("Arial", 0, 12));
        txtAConsola.setForeground(new java.awt.Color(255, 255, 255));
        txtAConsola.setRows(5);
        txtAConsola.setWrapStyleWord(true);
        txtAConsola.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        txtAConsola.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtAConsolaKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtAConsolaKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtAConsolaKeyTyped(evt);
            }
        });
        jScrollPane3.setViewportView(txtAConsola);

        txtComando.setBackground(new java.awt.Color(0, 0, 0));
        txtComando.setForeground(new java.awt.Color(255, 255, 255));
        txtComando.setCaretColor(new java.awt.Color(255, 255, 255));
        txtComando.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        txtComando.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtComandoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtComandoKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout panelConsolaLayout = new javax.swing.GroupLayout(panelConsola);
        panelConsola.setLayout(panelConsolaLayout);
        panelConsolaLayout.setHorizontalGroup(
            panelConsolaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelConsolaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelConsolaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                    .addComponent(txtComando, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelConsolaLayout.setVerticalGroup(
            panelConsolaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsolaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtComando, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(168, Short.MAX_VALUE))
        );

        PestañasConfiguraciones.addTab("Consola", new javax.swing.ImageIcon(getClass().getResource("/tsb/UI/Imagenes/CONSOLA_16x16.png")), panelConsola); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PestañasConfiguraciones, javax.swing.GroupLayout.PREFERRED_SIZE, 425, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PestañasConfiguraciones)
        );
    }// </editor-fold>//GEN-END:initComponents

    
    
    private void insertarPanel(javax.swing.JPanel p, String panel)
    {
        if(!this.pestaña1)
         {
             this.panelPestaña1.add(p);
             pestañasInterfaces.setTitleAt(0, panel);
             this.pestaña1=true;
             
         }
         else
         {
             this.panelPestaña2.add(p);
             pestañasInterfaces.setTitleAt(1, panel);
             this.pestaña2=true;
             this.btnQuitarInterfazPestaña2.setVisible(true);
         }
    
    }
    public void habilitarText()
    {
        this.txtGateway.setEnabled(true);
        this.txtServidorDNS.setEnabled(true);
    }
    public void deshabilitarText()
    {
        this.txtGateway.setEnabled(false);
        this.txtServidorDNS.setEnabled(false);
    }

    private void insertarPanelPosicion(javax.swing.JPanel p, String panel, int orden)
    {
        switch(orden)
        {
            case 0:
                  this.panelPestaña1.add(p);
                  pestañasInterfaces.setTitleAt(0, panel);
                  this.pestaña1=true;
                break;
            case 1:
                 this.panelPestaña2.add(p);
                 pestañasInterfaces.setTitleAt(1, panel);
                 this.pestaña2=true;
                 this.btnQuitarInterfazPestaña2.setVisible(true);
                break;
        }


       
    }


    public boolean getDhcpOStatic()
    {
        if (this.rbtDCHP.isSelected())
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    public boolean existeGateway()
    {
        if(this.txtGateway.getText().compareTo("")==0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    public boolean existeDns()
    {
        if(this.txtServidorDNS.getText().compareTo("")==0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    
    private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
    
        if(!this.pestaña1 || !this.pestaña2)
        {
             switch(this.cmbIntefaces.getSelectedIndex()) {
                 case 0:
                     PanelEthernet pe = new PanelEthernet();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pe,"Ethernet");
                     break;
                 case 1:
                     PanelFastEthernetRJ45 pfe = new PanelFastEthernetRJ45();
                     pfe.setAsignacion(this.getAsignacionIP());
                     pfe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pfe,"Fast Ethernet RJ45");
                     break;
                 case 2:
                     PanelFastEthernetFibra pfef = new PanelFastEthernetFibra();
                     pfef.setAsignacion(this.getAsignacionIP());
                     pfef.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pfef,"Fast Ethernet Fibra Óptica");
                     break;
                 case 3:
                     PanelGigabitRJ45 pg = new PanelGigabitRJ45();
                     pg.setAsignacion(this.getAsignacionIP());
                     pg.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pg,"Gigabit RJ45");
                     break;
                 case 4:
                     PanelGigabitFibra pgf = new PanelGigabitFibra();
                     pgf.setAsignacion(this.getAsignacionIP());
                     pgf.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pgf,"Gigabit Fibra Óptica");
                     break;
                 case 5:
                     PanelModemPC pm = new PanelModemPC();
                   //  pm.setAsginarIP(this.getAsignacionIP());
                     pm.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pm,"Modem");
                     break;
                 case 6:
                     PanelSerial ps = new PanelSerial();
                     ps.setAsignacion(this.getAsignacionIP());
                     ps.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(ps,"Serial");
                     break;
                 case 7:
                     PanelWireless pw = new PanelWireless();
                     pw.setAsignacionIP(this.getAsignacionIP());
                     pw.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanel(pw,"Wireless");
                     break;
             }
        }
        else
        {
            VentanaDeError.mostrarDialog("No se puede agregar interfaz", "             La PC solo acepta 2 Interfaces de coneccion.\nPara agregar una nueva debe quitar alguna de las interfaces actuales", 0);
        }
}//GEN-LAST:event_btnAgregarActionPerformed

    public void agregarInterfaces(ArrayList listaInterfaces)
    {
        int contador= 0;
        int val=0;
        Iterator iter= listaInterfaces.iterator();
        while(iter.hasNext())
        {
           InterfaceDeConeccion i= (InterfaceDeConeccion)iter.next();
          
           if(i instanceof Ethernet)
           {
                     PanelEthernet pe = new PanelEthernet();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Ethernet",contador);
                     pe.setCampos((Ethernet)i);
                     contador++;
                     
           }
          if(i instanceof FibraOpticaFastEthernet)
          {
                     PanelFastEthernetFibra pe = new PanelFastEthernetFibra();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Fast Ethernet Fibra",contador);
                     pe.setCampos((FibraOpticaFastEthernet)i);
                     contador++;
                   
          }
          if(i instanceof FastEthernet)
          {
                     PanelFastEthernetRJ45 pe = new PanelFastEthernetRJ45();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Fast Ethernet RJ45",contador);
                     pe.setCampos((FastEthernet)i);
                     contador++;
                    
          }
          if(i instanceof RJ45Gigabit)
          {
                     PanelGigabitRJ45 pe = new PanelGigabitRJ45();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Gigabit RJ45",contador);
                     pe.setCampos((RJ45Gigabit)i);
                     contador++;
          }
          if(i instanceof FibraOpticaGigabit)
          {
                     PanelGigabitFibra pe = new PanelGigabitFibra();
                     pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Gigabit Fibra Óptica",contador);
                     pe.setCampos((FibraOpticaGigabit)i);
                     contador++;
          }
          if(i instanceof InterfazModemPC)
          {
                     PanelModemPC pe = new PanelModemPC();
                   //  pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Modem",contador);
                     pe.setCampos((InterfazModemPC)i);
                     contador++;
          }
          if(i instanceof Serial)
          {
                     PanelSerial pe = new PanelSerial();
                   //  pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Modem",contador);
                     pe.setCampos((Serial)i);
                     contador++;
          }
          if(i instanceof Wireless)
          {
                     PanelWireless pe = new PanelWireless();
                   //  pe.setAsignacion(this.getAsignacionIP());
                     pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                     this.insertarPanelPosicion(pe,"Wireless",contador);
                     pe.setCampos((Wireless)i);
                     contador++;
          }
        }
    }



    private void rbtStaticMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rbtStaticMouseClicked
        this.txtGateway.setEnabled(true);
        this.txtServidorDNS.setEnabled(true);
        
        //this.pestaña1 this.pestaña2        
        // 0 0 -> 0
        // 0 1 -> 1
        // 1 0 -> 1
        // 1 1 -> 1
        if(this.pestaña1 || this.pestaña2)
        {
            if(this.pestaña1 && this.pestaña2)
            {//
                this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.Static);
                this.setAsignacionIPPanel(this.panelPestaña2,AsignacionIP.Static);
            }
            else
            {
                if(this.pestaña1)
                {
                    this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.Static);
                    //this.setAsigancioIPPanel1(AsignacionIP.Static);
                }
                else
                {
                      this.setAsignacionIPPanel(this.panelPestaña2,AsignacionIP.Static);
                    //this.setAsigancioIPPanel2(AsignacionIP.Static);
                }
            }
        }
//        if(this.pestaña1 || this.pestaña2)
//        {
//            if(this.pestaña1 && this.pestaña2)
//            {//
//                this.setAsigancioIPPanel1(AsignacionIP.Static);
//                this.setAsigancioIPPanel2(AsignacionIP.Static);
//            }
//            else
//            {
//                if(this.pestaña1)
//                {
//                    this.setAsigancioIPPanel1(AsignacionIP.Static);
//                }
//                else
//                {
//                    this.setAsigancioIPPanel2(AsignacionIP.Static);
//                }
//            }
//        }
        
    }//GEN-LAST:event_rbtStaticMouseClicked

    
//    private void setAsigancioIPPanel1(AsignacionIP a)
//    {
//         if(this.panelPestaña1.getComponent(1) instanceof tsb.UI.Paneles.PanelEthernet)
//        {
//           PanelEthernet pe = (PanelEthernet)this.panelPestaña1.getComponent(1);
//           pe.setAsignacion(a);
//           return;
//        }
//
//        if(this.panelPestaña1.getComponent(1) instanceof PanelFastEthernetRJ45)
//        {
//            PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)this.panelPestaña1.getComponent(1);
//             pe.setAsignacion(a);
//             return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelFastEthernetFibra)
//        {
//            PanelFastEthernetFibra pe = (PanelFastEthernetFibra)this.panelPestaña1.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelGigabitRJ45)
//        {
//            PanelGigabitRJ45 pe = (PanelGigabitRJ45)this.panelPestaña1.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelGigabitFibra)
//        {
//            PanelGigabitFibra pe = (PanelGigabitFibra)this.panelPestaña1.getComponent(1);
//            pe.setAsignacion(a);
//            return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelSerial)
//        {
//            PanelSerial pe = (PanelSerial)this.panelPestaña1.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelModemPC)
//        {
//            PanelModemPC pe = (PanelModemPC)this.panelPestaña1.getComponent(1);
//             pe.setAsginarIP(a);
//           return;
//        }
//         if(this.panelPestaña1.getComponent(1) instanceof PanelWireless)
//        {
//            PanelWireless pe = (PanelWireless)this.panelPestaña1.getComponent(1);
//             pe.setAsignacionIP(a);
//           return;
//        }
//        
//    }
   
    private void setAsignacionIPPanel(javax.swing.JPanel p, AsignacionIP ip)
    {
         if(p.getComponent(0) instanceof tsb.UI.Paneles.PC.PanelEthernet)
        {
           PanelEthernet pe = (PanelEthernet)p.getComponent(0);
           pe.setAsignacion(ip);
           return;
        }

        if(p.getComponent(0) instanceof PanelFastEthernetRJ45)
        {
            PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)p.getComponent(0);
             pe.setAsignacion(ip);
             return;
        }
        if(p.getComponent(0) instanceof PanelFastEthernetFibra)
        {
            PanelFastEthernetFibra pe = (PanelFastEthernetFibra)p.getComponent(0);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(0) instanceof PanelGigabitRJ45)
        {
            PanelGigabitRJ45 pe = (PanelGigabitRJ45)p.getComponent(0);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(0) instanceof PanelGigabitFibra)
        {
            PanelGigabitFibra pe = (PanelGigabitFibra)p.getComponent(0);
            pe.setAsignacion(ip);
            return;
        }
        if(p.getComponent(0) instanceof PanelSerial)
        {
            PanelSerial pe = (PanelSerial)p.getComponent(0);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(0) instanceof PanelModemPC)
        {
            PanelModemPC pe = (PanelModemPC)p.getComponent(0);
            // pe.setAsginarIP(ip);
           return;
        }
         if(p.getComponent(0) instanceof PanelWireless)
        {
            PanelWireless pe = (PanelWireless)p.getComponent(0);
             pe.setAsignacionIP(ip);
           return;
        }
        
    }
//    private void setAsigancioIPPanel2(AsignacionIP a)
//    {
//        if(this.panelPestaña2.getComponent(1) instanceof tsb.UI.Paneles.PanelEthernet)
//        {
//           PanelEthernet pe = (PanelEthernet)this.panelPestaña2.getComponent(1);
//           pe.setAsignacion(a);
//           return;
//        }
//
//        if(this.panelPestaña2.getComponent(1) instanceof PanelFastEthernetRJ45)
//        {
//            PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)this.panelPestaña2.getComponent(1);
//             pe.setAsignacion(a);
//             return;
//        }
//        if(this.panelPestaña2.getComponent(1) instanceof PanelFastEthernetFibra)
//        {
//            PanelFastEthernetFibra pe = (PanelFastEthernetFibra)this.panelPestaña2.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña2.getComponent(1) instanceof PanelGigabitRJ45)
//        {
//            PanelGigabitRJ45 pe = (PanelGigabitRJ45)this.panelPestaña2.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña2.getComponent(1) instanceof PanelGigabitFibra)
//        {
//            PanelGigabitFibra pe = (PanelGigabitFibra)this.panelPestaña2.getComponent(1);
//            pe.setAsignacion(a);
//            return;
//        }
//        if(this.panelPestaña2.getComponent(1) instanceof PanelSerial)
//        {
//            PanelSerial pe = (PanelSerial)this.panelPestaña2.getComponent(1);
//             pe.setAsignacion(a);
//           return;
//        }
//        if(this.panelPestaña1.getComponent(1) instanceof PanelModemPC)
//        {
//            PanelModemPC pe = (PanelModemPC)this.panelPestaña1.getComponent(1);
//             pe.setAsginarIP(a);
//           return;
//        }
//        if(this.panelPestaña2.getComponent(1) instanceof PanelWireless)
//        {
//            PanelWireless pe = (PanelWireless)this.panelPestaña2.getComponent(1);
//             pe.setAsignacionIP(a);
//           return;
//        } 
//                    
//    
//    }
    
    private void rbtDCHPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rbtDCHPMouseClicked
        this.txtGateway.setEnabled(false);
        this.txtServidorDNS.setEnabled(false);
        
        
        if(this.pestaña1 || this.pestaña2)
        {
            if(this.pestaña1 && this.pestaña2)
            {//
                this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.DCHP);
                this.setAsignacionIPPanel(this.panelPestaña2,AsignacionIP.DCHP);
            }
            else
            {
                if(this.pestaña1)
                {
                    this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.DCHP);
                    //this.setAsigancioIPPanel1(AsignacionIP.Static);
                }
                else
                {
                      this.setAsignacionIPPanel(this.panelPestaña2,AsignacionIP.DCHP);
                    //this.setAsigancioIPPanel2(AsignacionIP.Static);
                }
            }
        }
//        if(this.pestaña1 || this.pestaña2)
//        {
//            if(this.pestaña1 && this.pestaña2)
//            {//
//                this.setAsigancioIPPanel1(AsignacionIP.DCHP);
//                this.setAsigancioIPPanel2(AsignacionIP.DCHP);
//            }
//            else
//            {
//                if(this.pestaña1)
//                {
//                    this.setAsigancioIPPanel1(AsignacionIP.DCHP);
//                }
//                else
//                {
//                    this.setAsigancioIPPanel2(AsignacionIP.DCHP);
//                }
//            }
//        }
    }//GEN-LAST:event_rbtDCHPMouseClicked

    private void btnQuitarInterfazPestaña2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarInterfazPestaña2ActionPerformed
        this.pestaña2=false;
        this.panelPestaña2.remove(this.panelPestaña2.getComponent(1));
         pestañasInterfaces.setTitleAt(1, "Interfaz 2");
        this.btnQuitarInterfazPestaña2.setVisible(false);
        

    }//GEN-LAST:event_btnQuitarInterfazPestaña2ActionPerformed

    private void txtAConsolaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAConsolaKeyPressed
        // TODO add your handling code here:
}//GEN-LAST:event_txtAConsolaKeyPressed

    private void txtAConsolaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAConsolaKeyReleased
        // TODO add your handling code here:
}//GEN-LAST:event_txtAConsolaKeyReleased

    private void txtAConsolaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAConsolaKeyTyped
        // TODO add your handling code here:
}//GEN-LAST:event_txtAConsolaKeyTyped

    private void txtComandoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtComandoKeyPressed
        // TODO add your handling code here:
}//GEN-LAST:event_txtComandoKeyPressed

    private void txtComandoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtComandoKeyReleased

        if(evt.getKeyCode()==KeyEvent.VK_ENTER)//si se aprieta enter
        {
            String comando=this.txtComando.getText();
            String operacion=comando.split(" ")[0];
            String ipDestino= comando.split(" ")[1];
            if(operacion.compareTo("ping")==0)
            {
              String ipOrigen= this.ventanaPC.getPC().getInterfaces().get(0).getIP().toString();
             if( this.ventanaPC.getGestorDeDispositivos().getGestorGrafo().ping(ipOrigen, ipDestino))
             {
                 this.txtAConsola.append("Haciendo ping a "+ipDestino+" con 32 bytes de datos:"+"\n"+
                                         "Respuesta desde "+ ipDestino+": bytes=32 tiempo=188ms TTL=128"+"\n"+
                                         "Respuesta desde "+ipDestino+": bytes=32 tiempo=2ms TTL=128"+"\n"+
                                         "Respuesta desde "+ipDestino+": bytes=32 tiempo=2ms TTL=128"+"\n"+
                                         "Respuesta desde "+ipDestino+": bytes=32 tiempo=2ms TTL=128"+"\n"+
                                         "\n"+
                                         "\n"+
                                         "Estadísticas de ping para "+ipDestino+":"+
                                         "Paquetes: enviados = 4, recibidos = 4, perdidos = 0"+
                                         "(0% perdidos),"+
                                         "Tiempos aproximados de ida y vuelta en milisegundos:"+
                                         "Mínimo = 2ms, Máximo = 188ms, Media = 48ms");
             }
            else
            {
                  this.txtAConsola.append("Haciendo ping a "+ipDestino+" con 32 bytes de datos:"+"\n"+
                                          "Respuesta desde "+ipDestino+": Host de destino inaccesible."+"\n"+
                                          "Respuesta desde "+ipDestino+": Host de destino inaccesible."+"\n"+
                                          "Respuesta desde "+ipDestino+": Host de destino inaccesible."+"\n"+
                                          "Respuesta desde "+ipDestino+": Host de destino inaccesible."+"\n"+
                                          "\n"+
                                          "\n"+
                                          "Estadísticas de ping para "+ipDestino+":"+"\n"+
                                          "Paquetes: enviados = 4, recibidos = 4, perdidos = 0"+"\n"+
                                          "(0% perdidos),");
            }


               
           }

            
        }


}//GEN-LAST:event_txtComandoKeyReleased
  

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane PestañasConfiguraciones;
    private javax.swing.ButtonGroup btgrAsingacionIP;
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnQuitarInterfazPestaña2;
    private javax.swing.JComboBox cmbEncendido;
    private javax.swing.JComboBox cmbIntefaces;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JPanel panelConsola;
    private javax.swing.JPanel panelPestaña1;
    private javax.swing.JPanel panelPestaña2;
    private javax.swing.JTabbedPane pestañasInterfaces;
    private javax.swing.JRadioButton rbtDCHP;
    private javax.swing.JRadioButton rbtStatic;
    private javax.swing.JTextArea txtAConsola;
    private javax.swing.JTextField txtComando;
    private javax.swing.JTextField txtGateway;
    private javax.swing.JTextField txtNombreAMostrar;
    private javax.swing.JTextField txtServidorDNS;
    // End of variables declaration//GEN-END:variables

    public void setNombreAMostrar(String nombre)
    {
        this.txtNombreAMostrar.setText(nombre);
    }
    
    public String getNombreAMostrar()
    {
        return this.txtNombreAMostrar.getText();
    }

    public boolean getPestaña1() {
        return pestaña1;
    }

    public void setPestaña1(boolean pestaña1) {
        this.pestaña1 = pestaña1;
    }

    public boolean getPestaña2() {
        return pestaña2;
    }

    public void setPestaña2(boolean pestaña2) {
        this.pestaña2 = pestaña2;
    }

    
    public void setEncendido(boolean encendido)
    {
        if(encendido)
        {
            this.cmbEncendido.setSelectedIndex(0);
        }
        else
        {
            this.cmbEncendido.setSelectedIndex(1);
        }
    }
    
    public boolean getEncendido()
    {
        if(this.cmbEncendido.getSelectedIndex()==0)
            return true;
        else
            return false;
    }
    
    public void setAsignacionIP(AsignacionIP asignacion)
    {
        if(asignacion== AsignacionIP.DCHP)
        {
            this.rbtDCHP.setSelected(true);
        }
        else
        {
            this.rbtStatic.setSelected(true);
        }
    }
    
    public AsignacionIP getAsignacionIP()
    {
        if(this.rbtDCHP.isSelected())
            return AsignacionIP.DCHP;
        else
            return AsignacionIP.Static; 
    }
    
    public void setGateway(IP gw )
    {
        if(gw!=null)
        {
            this.txtGateway.setText(gw.toString());
        }
    }
    
    public IP getGateway()
    {
        IP ip = new IP(this.txtGateway.getText());
        return ip;
    }
    
    public void setServidorDNS(IP dns)
    {
        if(dns!=null)
        {
            this.txtServidorDNS.setText(dns.toString());
        }
    }
    
    public IP getServdorDNS()
    {
        IP dns = new IP(this.txtServidorDNS.getText());
        return dns;
    }
    
//    public ArrayList<InterfaceDeConeccion> getInterfaces()
//    {
//        return this.listaInterfaces;
//    }
//
    public InterfaceDeConeccion getInterfaz1()
    {
   
           PanelEthernet pe = (PanelEthernet)this.panelPestaña1.getComponent(0);
            return pe.getEthernet();
      
    }
   

    public InterfaceDeConeccion getInterfaz2()
    {
        
        if(this.panelPestaña2.getComponent(1) instanceof tsb.UI.Paneles.PC.PanelEthernet)
                      {
                       PanelEthernet pe = (PanelEthernet)this.panelPestaña2.getComponent(1);
                        return pe.getEthernet();
                              }
                    else
                    {
                        if(this.panelPestaña2.getComponent(1) instanceof PanelFastEthernetRJ45)
                        {
                            PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)this.panelPestaña2.getComponent(1);
                            return pe.getRJ45FastEthernet();
                        }
                        else
                        {
                            if(this.panelPestaña2.getComponent(1) instanceof PanelFastEthernetFibra)
                            {
                                PanelFastEthernetFibra pe = (PanelFastEthernetFibra)this.panelPestaña2.getComponent(1);
                                return pe.getFibraOpticaFastEthernet();
                            }
                            else
                            {
                                if(this.panelPestaña2.getComponent(1) instanceof PanelGigabitRJ45)
                                {
                                    PanelGigabitRJ45 pe = (PanelGigabitRJ45)this.panelPestaña2.getComponent(1);
                                    return pe.getFibraOpticaGigabit();
                                }
                                else
                                {
                                    if(this.panelPestaña2.getComponent(1) instanceof PanelGigabitFibra)
                                    {
                                        PanelGigabitFibra pe = (PanelGigabitFibra)this.panelPestaña2.getComponent(1);
                                        return pe.getFibraOpticaGigabit();
                                    }
                                    else
                                    {
                                        if(this.panelPestaña2.getComponent(1) instanceof PanelModemPC)
                                        {
                                            PanelModemPC pe = (PanelModemPC)this.panelPestaña2.getComponent(1);
                                            return pe.getInterfazModem();
                                        }
                                        else
                                        {
                                            if(this.panelPestaña2.getComponent(1) instanceof PanelSerial)
                                            {
                                                PanelSerial pe = (PanelSerial)this.panelPestaña2.getComponent(1);
                                                return pe.getSerial();
                                            }
                                            else
                                            {
                                                 if(this.panelPestaña2.getComponent(1) instanceof PanelWireless)
                                                {
                                                    PanelWireless pe = (PanelWireless)this.panelPestaña2.getComponent(1);
                                                    return pe.getWireless();
                                                }
                                            }

                                        }

                                    }

                                }

                            }

                        
        }
     }

        return null;
    }
      
       class ComboBoxRenderer extends JLabel
                           implements ListCellRenderer {
        private Font uhOhFont;
 
        public ComboBoxRenderer() {
            setOpaque(true);
            setHorizontalAlignment(CENTER);
            setVerticalAlignment(CENTER);
        }
 
        /*
         * This method finds the image and text corresponding
         * to the selected value and returns the label, set up
         * to display the text and image.
         */
        public Component getListCellRendererComponent(
                                           JList list,
                                           Object value,
                                           int index,
                                           boolean isSelected,
                                           boolean cellHasFocus) {
            //Get the selected index. (The index param isn't
            //always valid, so just use the value.)
            int selectedIndex = ((Integer)value).intValue();
 
            if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
            } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            }
 
            //Set the icon and text.  If icon was null, say so.
            ImageIcon icon = images[selectedIndex];
            String pet = opciones[selectedIndex];
            setIcon(icon);
            if (icon != null) {
                setText(pet);
                setFont(list.getFont());
            } else {
                setUhOhText(pet + " (no image available)",
                            list.getFont());
            }
 
            return this;
        }
 
        //Set the font and text when no image was found.
        protected void setUhOhText(String uhOhText, Font normalFont) {
            if (uhOhFont == null) { //lazily create this font
                uhOhFont = normalFont.deriveFont(Font.ITALIC);
            }
            setFont(uhOhFont);
            setText(uhOhText);
        }
    }
    
}


